package club.zhilin.guli.service.edu.service.impl;

import club.zhilin.guli.service.edu.domain.Subject;
import club.zhilin.guli.service.edu.domain.vo.SubjectVO;
import club.zhilin.guli.service.edu.domain.dto.SubjectDTO;
import club.zhilin.guli.service.edu.listener.ExcelSubjectListener;
import club.zhilin.guli.service.edu.mapper.SubjectMapper;
import club.zhilin.guli.service.edu.service.ISubjectService;
import com.alibaba.excel.EasyExcelFactory;
import com.alibaba.excel.support.ExcelTypeEnum;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

import java.io.InputStream;
import java.util.List;

/**
 * <p>
 * 课程科目 服务实现类
 * </p>
 *
 * @author zhilin
 * @since 2022-01-11 15:29:01
 */
@Service
public class SubjectServiceImpl extends ServiceImpl<SubjectMapper, Subject> implements ISubjectService {

    @Override
    public void batchImport(InputStream inputStream) {
        EasyExcelFactory.read(inputStream, SubjectDTO.class, new ExcelSubjectListener(baseMapper)).excelType(ExcelTypeEnum.XLSX).excelType(ExcelTypeEnum.XLS).sheet().doRead();
    }

    @Override
    public List<SubjectVO> nestedList(String parentId) {
        return baseMapper.selectNestedList(parentId);
    }
}
